package com.zlm.String;

/**
 * @author 13026
 */
public class StringDemo {
    public static void main(String[] args) {
        // 字符转字符串
        char[] ch = {'a', 'b', 'c'};
        String s1 = new String(ch);
        System.out.println(s1);

        // 字节转字符串
        byte[] bt = {79, 80, 81};
        String s2 = new String(bt);
        System.out.println(s2);

        // 字符串比较
        // 直接赋值的字符串，在串池中，会缓存 s3 == s4
        String s3 = "abc";
        String s4 = "abc";
        System.out.println(s4 == s3);

        // new 的字符串，比较的地址值        s5 != s6
        String s5 = "abc";
        String s6 = "abc";
        System.out.println(s5 == s6);

        // equals 用来判断内容是否相等
        System.out.println(s5.equals(s6));

    }
}





